package kaizone.haining.chaobohui.login;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class CommentControl {
	public static final String REST = "http://api.dp-app.com/chao/remote/rest/";

	public static final String URL_QUERY_COMMENTS = REST + "query_comments.htm";
	
	protected String mUrl;
	
    public String requestString(HashMap<String, String> data) {
        StringBuffer sb = new StringBuffer();
        sb.append(URL_QUERY_COMMENTS).append("?");
        Iterator iterator = data.entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry<String, String> entry = (Map.Entry<String, String>) iterator.next();
            String key = entry.getKey();
            String value = entry.getValue();
            sb.append(key).append("=").append(value).append("&");
        }
        mUrl = sb.toString();
        return mUrl;
    }
    
    /**
     * 查询新闻评论
     * @param newsId
     * @return
     */
    public String requestQueryNews(String newsId){
    	HashMap<String, String> data = new HashMap<String, String>();
    	data.put("newsId", newsId);
    	return requestString(data);
    }
    
    public String requestQueryNews(int newsId){
    	String newsIdString = String.valueOf(newsId);
    	return requestQueryNews(newsIdString);
    }
    
    /**查询活动评论
     * @param activityId
     * @return
     */
    public String requestQueryActivity(String activityId){
    	HashMap<String, String> data = new HashMap<String, String>();
    	data.put("activityId", activityId);
    	return requestString(data);
    }
    
    public String requestQueryActivity(int activityId){
    	String activityIdString = String.valueOf(activityId);
    	return requestQueryActivity(activityIdString);
    }
    
    /**
     * 查询用户评论
     * @param userName
     * @param userAuth
     * @return
     */
    public String requestQueryUser(String userName, String userAuth){
    	HashMap<String, String> data = new HashMap<String, String>();
    	data.put("userName", userName);
    	data.put("userAuth", userAuth);
    	return requestString(data);
    }
    

}
